package com.jigsaw.model;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by Jigsaw on 2016/4/4.
 */
@Entity
@Table(name = "movies_cate", schema = "movies", catalog = "")
public class MoviesCateEntity {
    private int cid;
    private String category;
    private Set<MoviesInfoEntity> moviesById;

    @Id
    @Column(name = "cid", nullable = false)
    public int getCid() {
        return cid;
    }

    public void setCid(int cid) {
        this.cid = cid;
    }

    @Basic
    @Column(name = "category", nullable = false, length = 32)
    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MoviesCateEntity that = (MoviesCateEntity) o;

        if (cid != that.cid) return false;
        if (category != null ? !category.equals(that.category) : that.category != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = cid;
        result = 31 * result + (category != null ? category.hashCode() : 0);
        return result;
    }

    @OneToMany(mappedBy = "cateById")
    public Set<MoviesInfoEntity> getMoviesById() {
        return moviesById;
    }

    public void setMoviesById(Set<MoviesInfoEntity> moviesById) {
        this.moviesById = moviesById;
    }
}
